/***************************************************************************\
 * Copyright (C) by Keio University
 * Prototypes.hpp created in 06 2012.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * Prototypes.hpp is part of the HVRL Engine Library.
 *
 * The HVRL Engine Library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 \***************************************************************************/

#ifndef PROTOTYPES_HPP__
#define PROTOTYPES_HPP__

#include <hvrl/common/Common.hpp>

extern "C"
{
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cuda_gl_interop.h>
}

namespace hvrl
{

  namespace cuda
  {

  inline void
  assertStatus(const cudaError& err)
  {
    if (err != cudaSuccess)
      {
        std::cerr << "CUDA fatal error: " << cudaGetErrorString(err)
            << std::endl;
        exit(EXIT_FAILURE);
      }
  }

  inline bool
  checkStatus(const cudaError& err)
  {
    if (err != cudaSuccess)
      {
        std::cerr << "CUDA error: " << cudaGetErrorString(err) << std::endl;
        return false;
      }
    return true;
  }

    namespace kinectprocessing
    {

    /*  bool
      updateBackProjectionMatrix(const float& kinectbackprojection,
          const unsigned int& width, const unsigned int& height);*/

      void
      backProject(short unsigned int *d_input_vertex,
          unsigned char *d_input_color, float *d_output_vertex,
          float *d_output_color, float bpc, const int& d_width, const int& d_height);

    /*  void
      backProject(float *d_input_vertex,
          unsigned char *d_input_color, float *d_output_vertex,
          float *d_output_color, const int& d_width, const int& d_height);*/
    }

    namespace BilateralFilter
    {
      void
      setKernel(const float& sigma_s, const float& sigma_r, const int& radius);
      void
      computeC1(unsigned char* pSrc, unsigned char* pDest, const int& w,
          const int& h);
      void
      computeC1(short unsigned int* pSrc, short unsigned int* pDest,
          const int& w, const int& h);
      void
      computeC1(float* pSrc, float* pDest,
          const int& w, const int& h);
      void
      computeC3(unsigned char* pSrc, unsigned char* pDest, const int& w,
          const int& h);
    }
  }
}

#endif
